@extends('layouts.admin.master')

@section('content')
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <br/>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        商品分类列表

                        <div class="pull-right">
                            <a href="{{ route('admin.product_categories.create') }}" class="btn btn-success btn-xs"><i
                                        class="fa fa-plus fa-fw"></i>添加分类</a>
                        </div>
                    </div>
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table id="tableCategory" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>分类名称</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($treeArray as $v)
                                    <tr class="treegrid-{{$v[0]}} {{ $v[3] ==0 ? '' : 'treegrid-parent-' . $v[3] }}">
                                        <td>{{ $v[1] }}</td>
                                        <td>
                                            <a class="btn btn-info btn-xs"
                                               href="{{ route('admin.product_categories.edit', ['id' => $v[0]]) }}">编辑</a>

                                            <form action="{{ route('admin.product_categories.destroy', ['id' => $v[0]]) }}"
                                                  method="post" style="display: inline;"
                                                  onsubmit="return confirm('确认删除吗？这将同时删除它的子分类！！！');">
                                                {{ csrf_field() }}
                                                {{ method_field('DELETE') }}
                                                <button class="btn btn-danger btn-xs" type="submit">删除</button>
                                            </form>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <script type="text/javascript">
            $(document).ready(function() {
                $('#tableCategory').treegrid();
            });
        </script>
    </div>
@endsection